export type caseListType = {
  label: string;
  desc?: string;
  path?: string;
  children?: caseListType[];
};

export const reactCaseList: caseListType[] = [
  {
    label: "基础状态管理",
    path: "/basicCase",
    children: [
      {
        label: "useState",
        desc: "管理任意类型的状态",
        path: "/useStateCase",
      },
      { label: "useReducer", desc: "管理复杂状态逻辑" },
      {
        label: "useBoolean",
        desc: "专用于布尔状态，提供 toggle/setTrue/setFalse",
      },
      { label: "useToggle", desc: "在两个值之间切换（如 'on'/'off'）" },
      { label: "useCounter", desc: "数字计数器，提供 inc/dec/set/reset" },
      { label: "useSet", desc: "管理 Set 类型状态（add/remove/has/reset）" },
      { label: "useMap", desc: "管理 Map 类型状态（set/delete/get/has）" },
    ],
  },
  {
    label: "持久化状态",
    children: [
      {
        label: "useLocalStorageState",
        desc: "同步状态到 localStorage，页面刷新不丢失",
      },
      { label: "useSessionStorageState", desc: "同步状态到 sessionStorage" },
      { label: "useCookieState", desc: "读写 Cookie 状态" },
    ],
  },
  {
    label: "副作用与生命周期",
    children: [
      { label: "useEffect", desc: "组件挂载/更新/卸载时执行副作用" },
      {
        label: "useLayoutEffect",
        desc: "同步执行副作用（DOM 更新后、绘制前）",
      },
      { label: "useMount", desc: "仅在组件首次挂载时执行" },
      { label: "useUnmount", desc: "组件卸载时执行清理逻辑" },
      { label: "useUpdate", desc: "手动触发组件重新渲染" },
      { label: "useUpdateEffect", desc: "跳过首次执行，仅在更新时触发" },
      {
        label: "useUpdateLayoutEffect",
        desc: "useUpdateEffect 的 layout 版本",
      },
    ],
  },
  {
    label: "性能优化",
    children: [
      { label: "useMemo", desc: "缓存计算结果" },
      { label: "useCallback", desc: "缓存函数引用" },
      { label: "useCreation", desc: "语义化创建昂贵对象（替代 useMemo）" },
      { label: "useMemoizedFn", desc: "安全缓存函数，解决闭包 stale 问题" },
      { label: "useLatest", desc: "获取状态的最新值（避免闭包过期）" },
    ],
  },
  {
    label: "Ref 与 DOM 操作",
    children: [
      { label: "useRef", desc: "创建可变引用（访问 DOM 或保存 mutable 值）" },
      { label: "useImperativeHandle", desc: "自定义暴露给父组件的 ref 方法" },
      { label: "useClickAway", desc: "监听点击元素外部事件" },
      { label: "useEventListener", desc: "安全添加/移除事件监听器" },
      { label: "useSize", desc: "监听 DOM 元素尺寸变化" },
      { label: "useInViewport", desc: "判断元素是否在视口内" },
      { label: "useFullscreen", desc: "控制全屏状态" },
      { label: "useHover", desc: "监听鼠标悬停状态" },
      { label: "useFocusWithin", desc: "监听子元素获得焦点" },
    ],
  },
  {
    label: "异步操作与数据请求",
    children: [
      {
        label: "useRequest",
        desc: "核心异步 Hook：支持 loading/error/data、轮询、防抖、缓存等",
      },
      {
        label: "useAsyncEffect",
        desc: "在 useEffect 中使用 async/await（自动处理卸载取消）",
      },
    ],
  },
  {
    label: "防抖与节流",
    children: [
      { label: "useDebounce", desc: "对值进行防抖" },
      { label: "useDebounceFn", desc: "对函数进行防抖" },
      { label: "useThrottle", desc: "对值进行节流" },
      { label: "useThrottleFn", desc: "对函数进行节流" },
    ],
  },
  {
    label: "定时器",
    children: [
      { label: "useTimeout", desc: "安全的 setTimeout（自动清理）" },
      { label: "useInterval", desc: "安全的 setInterval（自动清理）" },
      {
        label: "useRafTimeout",
        desc: "基于 requestAnimationFrame 的高性能延迟执行",
      },
      {
        label: "useRafInterval",
        desc: "基于 requestAnimationFrame 的高性能循环执行",
      },
    ],
  },
  {
    label: "浏览器与设备 API",
    children: [
      { label: "useContext", desc: "订阅 React Context 变化" },
      { label: "useNetwork", desc: "监听网络状态（online/offline）" },
      { label: "useOnline", desc: "获取当前是否在线" },
      { label: "useBattery", desc: "获取设备电池状态" },
      { label: "useClipboard", desc: "读写系统剪贴板" },
      { label: "useTitle", desc: "动态设置页面标题" },
      { label: "useFavicon", desc: "动态更换页面 favicon" },
      {
        label: "useDocumentVisibility",
        desc: "监听页面可见性变化（切换 Tab）",
      },
      {
        label: "usePageVisibility",
        desc: "同 useDocumentVisibility，语义更清晰",
      },
      { label: "useResponsive", desc: "响应式断点（基于 window.matchMedia）" },
      { label: "useMedia", desc: "自定义媒体查询监听" },
    ],
  },
  {
    label: "URL 与路由相关",
    children: [
      { label: "useLocation", desc: "解析当前 URL 的 search 和 hash" },
      { label: "useUrlState", desc: "将状态同步到 URL 查询参数（如 ?page=2）" },
    ],
  },
  {
    label: "工具辅助",
    children: [
      { label: "usePrevious", desc: "获取上一次渲染的值" },
      { label: "useHistoryTravel", desc: "实现状态的前进/后退（undo/redo）" },
      { label: "useForm", desc: "轻量级表单状态管理" },
      { label: "useSearch", desc: "带防抖的搜索输入处理" },
    ],
  },
];
